<?php
	session_start();
	require 'sistema/configuracao.php';
	
	$lang = ($_SESSION['lang']) ? $_SESSION['lang'] : $_COOKIE['lang'];
	
	// carrega o idioma de acordo com a lingua passada
	if($lang){
		$l = str_replace(".","",$lang);
		require 'language/'.$l.'.php';
	} else {
		require 'language/pt_br.php';
	}

	// exemplo de url
	# index.php?m=Bproject&c=formulario
	# index.php?m=Fproject&c=formulario // para o frontend

	//$con = Sistema_Conecta::getConexao();

	//index.php?m=backend_projects&c=formulario
	
	$controle = new Sistema_Controle();
	$controle->executa();

	// Chama layout	
	$smarty = Sistema_layout::instanciar();

	$smarty->assign('loginName',Sistema_Login::getNome());

	// se for o frontend entao pega a tela inicial do site senao pega o backend
	if(Sistema_Variavel::get('externo')){
		$smarty->exibir("frontempty.tpl.html");		
	} else if($_GET['m'] == "Ffront") {
		$smarty->exibir("frontendIndex.tpl.html");
	} else if($_GET['m'] != 'Blogin'){
		$smarty->exibir();
	}
?>